// components/customnav/index.js
const App = getApp();

Component({
  options: {
    multipleSlots: true
  },
  /**
   * 组件的对外属性，是属性名到属性设置的映射表
   */
  properties: {
    title: String,
  },

  /**
   * 组件的内部数据，和 properties 一同用于组件的模板渲染
   */
  data: {
    statusBarHeight: 0,
    navTitleHeight: 0,
    isIOS:false,
    navHeight: App.globalData.navHeight,
    navTop: App.globalData.navTop,
    windowHeight: App.globalData.windowHeight,
    menuButtonObject: App.globalData.menuButtonObject //小程序胶囊信息
  },
  // 组件数据字段监听器，用于监听 properties 和 data 的变化
  observers: {

  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function () {
      this.getSystemTab()
    },
    hide: function () {},
    resize: function () {},
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getSystemTab() {
      let res = wx.getSystemInfoSync()
      let buttonInfo = wx.getMenuButtonBoundingClientRect()
      let navBarHeight =
        (buttonInfo.top - res.statusBarHeight) * 2 + buttonInfo.height
      let _navBarHeight =
        (navBarHeight * 750) / wx.getSystemInfoSync().windowWidth //导航栏高度
      this.setData({
        navTitleHeight: _navBarHeight,
        statusBarHeight: (res.statusBarHeight * 750) / wx.getSystemInfoSync().windowWidth //状态栏高度
      })
      if(res.platform == 'ios') {
        this.setData({
          isIOS:true
        })
      }
      if(res.platform == 'android') {
        this.setData({
          isIOS:false
        })
      }
    }
  }
})